﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace ServiceGUI
{
    public partial class LoginControl : UserControl
    {

        public delegate void SetUser(string login, string mode);

        private SetUser _setter;
        private WorkBase.ServerClient _client;

        public LoginControl(SetUser setter, WorkBase.ServerClient client)
        {
            InitializeComponent();
            _setter = setter;
            _client = client;
        }

        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            _client.IsValidLoginPasswordCompleted += new EventHandler<WorkBase.IsValidLoginPasswordCompletedEventArgs>(server_IsValidLoginPasswordCompleted);
            _client.IsValidLoginPasswordAsync(LoginBox.Text, PassBox.Password);
        }

        void server_IsValidLoginPasswordCompleted(object sender, WorkBase.IsValidLoginPasswordCompletedEventArgs e)
        {
            _setter(LoginBox.Text, e.Result);
        }
    }
}
